#include "LagDrawer.h"
#include"../DxLib/DxLib.h"

LagDrawer::LagDrawer(const char* filepath,int intervalFrame,int lagNum):BaseDrawer(filepath),
	_intervalFrame(intervalFrame/lagNum),
	_lagNum(lagNum)
{
	_frame=1;
}

LagDrawer::~LagDrawer(void)
{
}

void
LagDrawer::Draw(){
	Positions_t::iterator it=_lagPositions.begin();
	int count=0;
	for(;it!=_lagPositions.end();++it){
		DxLib::SetDrawBlendMode(DX_BLENDMODE_ADD,255 - (++count) * (256/_lagNum));
		BaseDrawer::Draw((*it));
	}
	DxLib::SetDrawBlendMode(DX_BLENDMODE_NOBLEND,0);
	BaseDrawer::Draw();
	if(_frame==0){
		if(_lagPositions.size()>=_lagNum){
			_lagPositions.pop_back();
		}
		_lagPositions.push_front(_position);
	}
	_frame = (++_frame)%_intervalFrame;

	
}
